#ifndef STOPWATCH_HPP
#define STOPWATCH_HPP

#ifdef _WIN32
#include <windows.h>
#include <time.h>
#else
#include <sys/time.h>
#endif
#include <cstdio>

class Stopwatch {
  public:
    Stopwatch();
    ~Stopwatch();
    void start();
    void stop();
    double secondsElapsed();
    void print(const char* msg);
    char * toString(const char* msg);
  private:
    bool running;
    char buffer[256];
#ifdef _WIN32
    LARGE_INTEGER startTime;
    LARGE_INTEGER endTime;
#else
    timeval startTime;
    timeval endTime;
#endif
};

#endif
